﻿using Android.Content;
using Android.Util;
using Android.Views;
using Android.Widget;
using Google.Android.Material.Button;

namespace MagicBooks.Controls;

public class BookPresenterControl : LinearLayout
{
    private Button readButton;

    public BookPresenterControl(Context context) : base(context)
    {
        Initialize(context);
    }

    public BookPresenterControl(Context context, IAttributeSet attrs) : base(context, attrs)
    {
        Initialize(context);
    }

    private void Initialize(Context context)
    {
        var inflater = LayoutInflater.From(context);
        var view = inflater?.Inflate(Resource.Layout.control_bookpresenter, this, false);
        readButton = view?.FindViewById<Button>(Resource.Id.readButton);
        if (readButton != null)
            readButton.Click += (s, e) => { readButton.Text = "Reading"; };
        this.AddView(view);
    }
}